package cn.siat.gene.controller;

import cn.siat.common.core.web.controller.BaseController;
import cn.siat.common.core.web.domain.AjaxResult;
import cn.siat.common.security.utils.SecurityUtils;
import cn.siat.gene.domain.UploadInfo;
import cn.siat.gene.service.UploadInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Api(tags = "上传信息")
@RestController
@RequestMapping("/uploadInfo")
@RequiredArgsConstructor
@Slf4j
public class UploadInfoController extends BaseController {

    private final UploadInfoService uploadInfoService;


    @GetMapping("list")
    public AjaxResult list(String uploadStates){
        String[] states = uploadStates.split(",");
        QueryWrapper<UploadInfo>queryWrapper =new QueryWrapper<>();
        queryWrapper.eq("create_by", SecurityUtils.getUserId());
        queryWrapper.in("upload_state", states);
        List<UploadInfo> list = uploadInfoService.list(queryWrapper);
        return AjaxResult.success(list);
    }
    @PostMapping("save")
    public AjaxResult save(@RequestBody UploadInfo uploadInfo){
        uploadInfo.setUploadState(1);
        uploadInfo.setCreateBy(SecurityUtils.getUserId());
        uploadInfo.setCreateTime(new Date());
        return null;
    }

}
